package com.thoughtworks.jspecsupport.settings;

import javax.swing.*;
import java.awt.*;

public class JSpecSupportSettingsPanel {

    private JPanel panel;
    private String testLibFolder;
    private String prodJsFolder;
    private JTextField prodJsFolderTextField;
    private JTextField testLibFolderTextField;

    public JSpecSupportSettingsPanel(String prodJsFolder, String testLibFolder) {
        this.prodJsFolder = prodJsFolder;
        this.testLibFolder = testLibFolder;
        createPanel();
    }

    private void createPanel() {
        this.panel = new JPanel();
        panel.setSize(400, 400);
        panel.setLayout(new GridLayout(6, 2, 5, 5));

        panel.add(createLabel("Prod js folder: "));
        prodJsFolderTextField = createTextField(prodJsFolder);
        panel.add(prodJsFolderTextField);

        panel.add(createLabel("Test lib folder: "));
        testLibFolderTextField = createTextField(testLibFolder);
        panel.add(testLibFolderTextField);
    }

    private JTextField createTextField(String prodJsFolder) {
        return new JTextField(prodJsFolder);
    }

    private Component createLabel(String text) {
        return new JLabel(text);
    }

    public JComponent getPanel() {
        return panel;
    }

    public String getProdJsFolder() {
        return prodJsFolderTextField.getText();
    }

    public String getTestLibFolder() {
        return testLibFolderTextField.getText();
    }
}
